
public class ServerTest {

	public static void main(String[] args) {
		System.out.println("Creating/getting bankstubs");
    	Bank bank1 = new BankStub(1, "localhost");

        System.out.println("\nCreating/getting Accounts in bank");
        Account bent = bank1.getAccount("bent");
        Account bente = bank1.getAccount("bente");
        Account bentley = bank1.getAccount("bentley");
        printAccount(bent, true); printAccount(bente, true); printAccount(bentley, true);
        
        System.out.println("\nTesting balance changes");
        balanceChange(1500, bent);
        balanceChange(-1000, bent); System.out.println();

        balanceChange(1, bente);
        balanceChange(-2, bente); System.out.println();

        balanceChange(-12.25, bentley);
        balanceChange(12.25, bentley);
        
	}
    
    private static void balanceChange(double balanceChange, Account account){
        printAccount(account, false);
        if(balanceChange > 0){
            System.out.println("\tDepositing " + balanceChange);
            account.deposit(balanceChange);
        }
        else{
            System.out.println("\tWithdrawing " + (-balanceChange));
            account.withdraw(-balanceChange);
        }
        printAccount(account,true);
    }
    
    private static void printAccount(Account account, boolean newline){
        System.out.print(account.getName() + " " + account.getBalance());
        if(newline) System.out.println();
    }

}
